Change in openvpn[master]: options: add IPv4 support to '--show-gateway <arg>'
A message that is not in the archive (sent off-list or not yet received): gerrit.1738150255000.Ic438c583a782035ecb9b5ea65702a768ae2585f5@...2715...
Attention is currently required from: flichtenheld, plaisthos.
Hello plaisthos, flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/881?usp=email
to review the following change.
Change subject: options: add IPv4 support to '--show-gateway <arg>'
......................................................................
options: add IPv4 support to '--show-gateway <arg>'
This is an old debug option, which used to print "the default routes found" for IPv4 and IPv6, and optionally "a route to a particular IPv6 target" if passed an argument.
With the work started in commit 0fcfc8381f60d we want this to handle IPv4 as well, mostly to be able to easily test per-platform get_default_gateway() implementations.
The implementation is simplistic - if <arg> can be parsed as an IPv4 or IPv6 address, that particular protocol lookup will do "the host route" and the other one will stick to "the default route".
---
M doc/man-sections/advanced-options.rst
M src/openvpn/options.c
2 files changed, 18 insertions(+), 8 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/81/881/1
doc/man-sections/advanced-options.rst +8 -4
@@ -9,13 +9,17 @@ :: --show-gateway + --show-gateway IPv4-target --show-gateway IPv6-target + For IPv4 it looks for a 0.0.0.0/0 route, or the specified IPv4 address + if the target can be parsed as an IPv4 address. For IPv6 this queries the route towards ::/128, or the specified IPv6 - target address if passed as argument. - For IPv4 on Linux, Windows, MacOS and BSD it looks for a 0.0.0.0/0 route. - If there are more specific routes, the result will not always be matching - the route of the IPv4 packets to the VPN gateway. + target address if the argument is an IPv6 address. + + Adding a target is helpful for diagnostics to see if OpenVPN will do + the right thing if there are more specific IPv4/IPv6 routes to a + VPN server. Advanced Expert Options
src/openvpn/options.c +10 -4
@@ -5858,16 +5858,22 @@ {struct route_gateway_info rgi;struct route_ipv6_gateway_info rgi6; -struct in6_addr remote =IN6ADDR_ANY_INIT ; +in_addr_t remote_ipv4 =0 ; +struct in6_addr remote_ipv6 =IN6ADDR_ANY_INIT ;openvpn_net_ctx_t net_ctx;VERIFY_PERMISSION (OPT_P_GENERAL );if (p[1 ]) { -get_ipv6_addr (p[1 ], &remote,NULL ,M_WARN ); +/* try parsing the argument as a v4 or v6 address - if +* possible, the output will show the exact route there, and +* "the default route" for the other protocol +*/ + remote_ipv4 =get_ip_addr (p[1 ],M_WARN ,NULL ); +get_ipv6_addr (p[1 ], &remote_ipv6,NULL ,M_WARN ); }net_ctx_init (NULL , &net_ctx); -get_default_gateway (&rgi,0 , &net_ctx); -get_default_gateway_ipv6 (&rgi6, &remote, &net_ctx); +get_default_gateway (&rgi, remote_ipv4, &net_ctx); +get_default_gateway_ipv6 (&rgi6, &remote_ipv6, &net_ctx);print_default_gateway (M_INFO , &rgi, &rgi6);openvpn_exit (OPENVPN_EXIT_STATUS_GOOD );/* exit point */ }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/881?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic438c583a782035ecb9b5ea65702a768ae2585f5
Gerrit-Change-Number: 881
Gerrit-PatchSet: 1
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: cron2, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/881?usp=email )
Change subject: options: add IPv4 support to '--show-gateway <arg>'
......................................................................
Patch Set 1: Code-Review-2
(3 comments)
Patchset:
PS1:
Doesn't work for me
File doc/man-sections/advanced-options.rst:
http://gerrit.openvpn.net/c/openvpn/+/881/comment/4991ae80_16c9b46c :
PS1, Line 12: --show-gateway IPv4-target
Please also update usage information
File src/openvpn/options.c:
http://gerrit.openvpn.net/c/openvpn/+/881/comment/2277d987_7a2196d9 :
PS1, Line 5875: get_default_gateway(&rgi, remote_ipv4, &net_ctx);
Does not seem to work for me. It always displays the system default gateway, not the gateway for the IP address.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/881?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic438c583a782035ecb9b5ea65702a768ae2585f5
Gerrit-Change-Number: 881
Gerrit-PatchSet: 1
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Wed, 29 Jan 2025 12:15:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: cron2, plaisthos.
stipa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/881?usp=email )
Change subject: options: add IPv4 support to '--show-gateway <arg>'
......................................................................
Patch Set 1: Code-Review-2
(1 comment)
Patchset:
PS1:
Looks good and with "route.c: improve get_default_gateway() logic on Windows" I see the correct gateway, but get_default_gateway() expects dest in host byte order, and get_ip_addr() returns address in network byte order.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/881?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic438c583a782035ecb9b5ea65702a768ae2585f5
Gerrit-Change-Number: 881
Gerrit-PatchSet: 1
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Wed, 29 Jan 2025 12:16:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: cron2, flichtenheld, plaisthos.
stipa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/881?usp=email )
Change subject: options: add IPv4 support to '--show-gateway <arg>'
......................................................................
Patch Set 1:
(1 comment)
File src/openvpn/options.c:
http://gerrit.openvpn.net/c/openvpn/+/881/comment/563e3fd7_cdc2b930 :
PS1, Line 5875: get_default_gateway(&rgi, remote_ipv4, &net_ctx);
Quoted 1 line
Does not seem to work for me. […]
To make it actually work you need https://gerrit.openvpn.net/c/openvpn/+/879
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/881?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic438c583a782035ecb9b5ea65702a768ae2585f5
Gerrit-Change-Number: 881
Gerrit-PatchSet: 1
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 29 Jan 2025 12:17:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: cron2, flichtenheld, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/881?usp=email )
Change subject: options: add IPv4 support to '--show-gateway <arg>'
......................................................................
Patch Set 1: Code-Review-1
(1 comment)
Patchset:
PS1:
The fact that does nothing useful is known. It will as start to work for different systems once they get implementations for the dest argument to get_default_gateway.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/881?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic438c583a782035ecb9b5ea65702a768ae2585f5
Gerrit-Change-Number: 881
Gerrit-PatchSet: 1
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 29 Jan 2025 12:24:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: cron2, plaisthos, stipa.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/881?usp=email )
Change subject: options: add IPv4 support to '--show-gateway <arg>'
......................................................................
Patch Set 1:
(1 comment)
File src/openvpn/options.c:
http://gerrit.openvpn.net/c/openvpn/+/881/comment/cfb295c1_88399e03 :
PS1, Line 5875: get_default_gateway(&rgi, remote_ipv4, &net_ctx);
Quoted 1 line
To make it actually work you need https://gerrit.openvpn. […]
Acknowledged
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/881?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic438c583a782035ecb9b5ea65702a768ae2585f5
Gerrit-Change-Number: 881
Gerrit-PatchSet: 1
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Wed, 29 Jan 2025 12:27:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Comment-In-Reply-To: stipa <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: cron2, flichtenheld, plaisthos, stipa.
Hello flichtenheld, plaisthos, stipa,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/881?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review-1 by flichtenheld
Change subject: options: add IPv4 support to '--show-gateway <arg>'
......................................................................
options: add IPv4 support to '--show-gateway <arg>'
This is an old debug option, which used to print "the default routes found" for IPv4 and IPv6, and optionally "a route to a particular IPv6 target" if passed an argument.
With the work started in commit 0fcfc8381f60d we want this to handle IPv4 as well, mostly to be able to easily test per-platform get_default_gateway() implementations.
The implementation is simplistic - if <arg> can be parsed as an IPv4 or IPv6 address, that particular protocol lookup will do "the host route" and the other one will stick to "the default route".
NOTE: as of this commit, there is no backend functionality for IPv4, so it will not actually print anything interesting. This will be added in further platform dependent commits.
v2: amend --help output
---
M doc/man-sections/advanced-options.rst
M src/openvpn/options.c
2 files changed, 19 insertions(+), 9 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/81/881/2
doc/man-sections/advanced-options.rst +8 -4
@@ -9,13 +9,17 @@ :: --show-gateway + --show-gateway IPv4-target --show-gateway IPv6-target + For IPv4 it looks for a 0.0.0.0/0 route, or the specified IPv4 address + if the target can be parsed as an IPv4 address. For IPv6 this queries the route towards ::/128, or the specified IPv6 - target address if passed as argument. - For IPv4 on Linux, Windows, MacOS and BSD it looks for a 0.0.0.0/0 route. - If there are more specific routes, the result will not always be matching - the route of the IPv4 packets to the VPN gateway. + target address if the argument is an IPv6 address. + + Adding a target is helpful for diagnostics to see if OpenVPN will do + the right thing if there are more specific IPv4/IPv6 routes to a + VPN server. Advanced Expert Options
src/openvpn/options.c +11 -5
@@ -788,7 +788,7 @@"\n" "General Standalone Options:\n" #ifdef ENABLE_DEBUG -"--show-gateway : Show info about default gateway.\n" +"--show-gateway [address]: Show info about gateway [to v4/v6 address].\n" #endif ;
@@ -5858,16 +5858,22 @@ {struct route_gateway_info rgi;struct route_ipv6_gateway_info rgi6; -struct in6_addr remote =IN6ADDR_ANY_INIT ; +in_addr_t remote_ipv4 =0 ; +struct in6_addr remote_ipv6 =IN6ADDR_ANY_INIT ;openvpn_net_ctx_t net_ctx;VERIFY_PERMISSION (OPT_P_GENERAL );if (p[1 ]) { -get_ipv6_addr (p[1 ], &remote,NULL ,M_WARN ); +/* try parsing the argument as a v4 or v6 address - if +* possible, the output will show the exact route there, and +* "the default route" for the other protocol +*/ + remote_ipv4 =get_ip_addr (p[1 ],M_WARN ,NULL ); +get_ipv6_addr (p[1 ], &remote_ipv6,NULL ,M_WARN ); }net_ctx_init (NULL , &net_ctx); -get_default_gateway (&rgi,0 , &net_ctx); -get_default_gateway_ipv6 (&rgi6, &remote, &net_ctx); +get_default_gateway (&rgi, remote_ipv4, &net_ctx); +get_default_gateway_ipv6 (&rgi6, &remote_ipv6, &net_ctx);print_default_gateway (M_INFO , &rgi, &rgi6);openvpn_exit (OPENVPN_EXIT_STATUS_GOOD );/* exit point */ }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/881?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic438c583a782035ecb9b5ea65702a768ae2585f5
Gerrit-Change-Number: 881
Gerrit-PatchSet: 2
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: cron2, plaisthos, stipa.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/881?usp=email )
Change subject: options: add IPv4 support to '--show-gateway <arg>'
......................................................................
Patch Set 2:
(1 comment)
File doc/man-sections/advanced-options.rst:
http://gerrit.openvpn.net/c/openvpn/+/881/comment/82a9dfc4_e8f99840 :
PS1, Line 12: --show-gateway IPv4-target
Quoted 1 line
Please also update usage information
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/881?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic438c583a782035ecb9b5ea65702a768ae2585f5
Gerrit-Change-Number: 881
Gerrit-PatchSet: 2
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Wed, 29 Jan 2025 16:57:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: cron2, plaisthos, stipa.
Hello flichtenheld, plaisthos, stipa,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/881?usp=email
to look at the new patch set (#3).
Change subject: options: add IPv4 support to '--show-gateway <arg>'
......................................................................
options: add IPv4 support to '--show-gateway <arg>'
This is an old debug option, which used to print "the default routes found" for IPv4 and IPv6, and optionally "a route to a particular IPv6 target" if passed an argument.
With the work started in commit 0fcfc8381f60d we want this to handle IPv4 as well, mostly to be able to easily test per-platform get_default_gateway() implementations.
The implementation is simplistic - if <arg> can be parsed as an IPv4 or IPv6 address, that particular protocol lookup will do "the host route" and the other one will stick to "the default route".
NOTE: as of this commit, there is no backend functionality for IPv4, so it will not actually print anything interesting. This will be added in further platform dependent commits.
v2: amend --help output
v3: uncrustify (#ifdef block too long, comments at #endif required now)
---
M doc/man-sections/advanced-options.rst
M src/openvpn/options.c
2 files changed, 20 insertions(+), 10 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/81/881/3
doc/man-sections/advanced-options.rst +8 -4
@@ -9,13 +9,17 @@ :: --show-gateway + --show-gateway IPv4-target --show-gateway IPv6-target + For IPv4 it looks for a 0.0.0.0/0 route, or the specified IPv4 address + if the target can be parsed as an IPv4 address. For IPv6 this queries the route towards ::/128, or the specified IPv6 - target address if passed as argument. - For IPv4 on Linux, Windows, MacOS and BSD it looks for a 0.0.0.0/0 route. - If there are more specific routes, the result will not always be matching - the route of the IPv4 packets to the VPN gateway. + target address if the argument is an IPv6 address. + + Adding a target is helpful for diagnostics to see if OpenVPN will do + the right thing if there are more specific IPv4/IPv6 routes to a + VPN server. Advanced Expert Options
src/openvpn/options.c +12 -6
@@ -788,7 +788,7 @@"\n" "General Standalone Options:\n" #ifdef ENABLE_DEBUG -"--show-gateway : Show info about default gateway.\n" +"--show-gateway [address]: Show info about gateway [to v4/v6 address].\n" #endif ;
@@ -5858,20 +5858,26 @@ {struct route_gateway_info rgi;struct route_ipv6_gateway_info rgi6; -struct in6_addr remote =IN6ADDR_ANY_INIT ; +in_addr_t remote_ipv4 =0 ; +struct in6_addr remote_ipv6 =IN6ADDR_ANY_INIT ;openvpn_net_ctx_t net_ctx;VERIFY_PERMISSION (OPT_P_GENERAL );if (p[1 ]) { -get_ipv6_addr (p[1 ], &remote,NULL ,M_WARN ); +/* try parsing the argument as a v4 or v6 address - if +* possible, the output will show the exact route there, and +* "the default route" for the other protocol +*/ + remote_ipv4 =get_ip_addr (p[1 ],M_WARN ,NULL ); +get_ipv6_addr (p[1 ], &remote_ipv6,NULL ,M_WARN ); }net_ctx_init (NULL , &net_ctx); -get_default_gateway (&rgi,0 , &net_ctx); -get_default_gateway_ipv6 (&rgi6, &remote, &net_ctx); +get_default_gateway (&rgi, remote_ipv4, &net_ctx); +get_default_gateway_ipv6 (&rgi6, &remote_ipv6, &net_ctx);print_default_gateway (M_INFO , &rgi, &rgi6);openvpn_exit (OPENVPN_EXIT_STATUS_GOOD );/* exit point */ } -#endif +#endif /* if defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL) */ else if (streq(p[0], "echo") || streq(p[0], "parameter")) {struct buffer string =alloc_buf_gc (OPTION_PARM_SIZE , &gc);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/881?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic438c583a782035ecb9b5ea65702a768ae2585f5
Gerrit-Change-Number: 881
Gerrit-PatchSet: 3
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: cron2, plaisthos.
stipa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/881?usp=email )
Change subject: options: add IPv4 support to '--show-gateway <arg>'
......................................................................
Patch Set 3: Code-Review+2
(1 comment)
Patchset:
PS3:
Note to myself - should not rely on printing ULONG when checking endianness.
Looks good and works as intended (discussed on IRC).
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/881?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic438c583a782035ecb9b5ea65702a768ae2585f5
Gerrit-Change-Number: 881
Gerrit-PatchSet: 3
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Wed, 29 Jan 2025 17:13:40 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v3 1/1 options: add IPv4 support to '--show-gateway <arg>'
In reply to a message not in the archiveThis is an old debug option, which used to print "the default routes found" for IPv4 and IPv6, and optionally "a route to a particular IPv6 target" if passed an argument.
With the work started in commit 0fcfc8381f60d we want this to handle IPv4 as well, mostly to be able to easily test per-platform get_default_gateway() implementations.
The implementation is simplistic - if <arg> can be parsed as an IPv4 or IPv6 address, that particular protocol lookup will do "the host route" and the other one will stick to "the default route".
NOTE: as of this commit, there is no backend functionality for IPv4, so it will not actually print anything interesting. This will be added in further platform dependent commits.
v2: amend --help output
v3: uncrustify (#ifdef block too long, comments at #endif required now)
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/881
This mail reflects revision 3 of this Change.
Acked-by according to Gerrit (reflected above):
Lev Stipakov <[email protected]...>
doc/man-sections/advanced-options.rst +8 -4
@@ -9,13 +9,17 @@ :: --show-gateway + --show-gateway IPv4-target --show-gateway IPv6-target + For IPv4 it looks for a 0.0.0.0/0 route, or the specified IPv4 address + if the target can be parsed as an IPv4 address. For IPv6 this queries the route towards ::/128, or the specified IPv6 - target address if passed as argument. - For IPv4 on Linux, Windows, MacOS and BSD it looks for a 0.0.0.0/0 route. - If there are more specific routes, the result will not always be matching - the route of the IPv4 packets to the VPN gateway. + target address if the argument is an IPv6 address. + + Adding a target is helpful for diagnostics to see if OpenVPN will do + the right thing if there are more specific IPv4/IPv6 routes to a + VPN server. Advanced Expert Options
src/openvpn/options.c +12 -6
@@ -788,7 +788,7 @@"\n" "General Standalone Options:\n" #ifdef ENABLE_DEBUG -"--show-gateway : Show info about default gateway.\n" +"--show-gateway [address]: Show info about gateway [to v4/v6 address].\n" #endif ;
@@ -5858,20 +5858,26 @@ {struct route_gateway_info rgi;struct route_ipv6_gateway_info rgi6; -struct in6_addr remote =IN6ADDR_ANY_INIT ; +in_addr_t remote_ipv4 =0 ; +struct in6_addr remote_ipv6 =IN6ADDR_ANY_INIT ;openvpn_net_ctx_t net_ctx;VERIFY_PERMISSION (OPT_P_GENERAL );if (p[1 ]) { -get_ipv6_addr (p[1 ], &remote,NULL ,M_WARN ); +/* try parsing the argument as a v4 or v6 address - if +* possible, the output will show the exact route there, and +* "the default route" for the other protocol +*/ + remote_ipv4 =get_ip_addr (p[1 ],M_WARN ,NULL ); +get_ipv6_addr (p[1 ], &remote_ipv6,NULL ,M_WARN ); }net_ctx_init (NULL , &net_ctx); -get_default_gateway (&rgi,0 , &net_ctx); -get_default_gateway_ipv6 (&rgi6, &remote, &net_ctx); +get_default_gateway (&rgi, remote_ipv4, &net_ctx); +get_default_gateway_ipv6 (&rgi6, &remote_ipv6, &net_ctx);print_default_gateway (M_INFO , &rgi, &rgi6);openvpn_exit (OPENVPN_EXIT_STATUS_GOOD );/* exit point */ } -#endif +#endif /* if defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL) */ else if (streq(p[0], "echo") || streq(p[0], "parameter")) {struct buffer string =alloc_buf_gc (OPTION_PARM_SIZE , &gc);
[Openvpn-devel] [PATCH applied] Re: options: add IPv4 support to '--show-gateway <arg>'
As the commit message states, there is not much meat behind this option yet - it's there to help testing the coming implementations. Lev tested this against his windows implementations, and we spent quite some time argueing host byte order, network byte order, and overall confusion on things memory ;-) (none of which plagues IPv6, if I may say so). Thanks.
Patch has been applied to the master branch.
commit 9df51cf56e27f6103ed5becbafd1f645726d9155
Author: Gert Doering Date: Wed Jan 29 18:30:07 2025 +0100
options: add IPv4 support to '--show-gateway <arg>'
Signed-off-by: Gert Doering <[email protected]...>
Acked-by: Lev Stipakov <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30728.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Hello flichtenheld, plaisthos, stipa,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/881?usp=email
to look at the new patch set (#4).
The following approvals got outdated and were removed:
Code-Review+2 by stipa
Change subject: options: add IPv4 support to '--show-gateway <arg>'
......................................................................
options: add IPv4 support to '--show-gateway <arg>'
This is an old debug option, which used to print "the default routes found" for IPv4 and IPv6, and optionally "a route to a particular IPv6 target" if passed an argument.
With the work started in commit 0fcfc8381f60d we want this to handle IPv4 as well, mostly to be able to easily test per-platform get_default_gateway() implementations.
The implementation is simplistic - if <arg> can be parsed as an IPv4 or IPv6 address, that particular protocol lookup will do "the host route" and the other one will stick to "the default route".
NOTE: as of this commit, there is no backend functionality for IPv4, so it will not actually print anything interesting. This will be added in further platform dependent commits.
v2: amend --help output
v3: uncrustify (#ifdef block too long, comments at #endif required now)
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30728.html
---
M doc/man-sections/advanced-options.rst
M src/openvpn/options.c
2 files changed, 20 insertions(+), 10 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/81/881/4
doc/man-sections/advanced-options.rst +8 -4
@@ -9,13 +9,17 @@ :: --show-gateway + --show-gateway IPv4-target --show-gateway IPv6-target + For IPv4 it looks for a 0.0.0.0/0 route, or the specified IPv4 address + if the target can be parsed as an IPv4 address. For IPv6 this queries the route towards ::/128, or the specified IPv6 - target address if passed as argument. - For IPv4 on Linux, Windows, MacOS and BSD it looks for a 0.0.0.0/0 route. - If there are more specific routes, the result will not always be matching - the route of the IPv4 packets to the VPN gateway. + target address if the argument is an IPv6 address. + + Adding a target is helpful for diagnostics to see if OpenVPN will do + the right thing if there are more specific IPv4/IPv6 routes to a + VPN server. Advanced Expert Options
src/openvpn/options.c +12 -6
@@ -788,7 +788,7 @@"\n" "General Standalone Options:\n" #ifdef ENABLE_DEBUG -"--show-gateway : Show info about default gateway.\n" +"--show-gateway [address]: Show info about gateway [to v4/v6 address].\n" #endif ;
@@ -5858,20 +5858,26 @@ {struct route_gateway_info rgi;struct route_ipv6_gateway_info rgi6; -struct in6_addr remote =IN6ADDR_ANY_INIT ; +in_addr_t remote_ipv4 =0 ; +struct in6_addr remote_ipv6 =IN6ADDR_ANY_INIT ;openvpn_net_ctx_t net_ctx;VERIFY_PERMISSION (OPT_P_GENERAL );if (p[1 ]) { -get_ipv6_addr (p[1 ], &remote,NULL ,M_WARN ); +/* try parsing the argument as a v4 or v6 address - if +* possible, the output will show the exact route there, and +* "the default route" for the other protocol +*/ + remote_ipv4 =get_ip_addr (p[1 ],M_WARN ,NULL ); +get_ipv6_addr (p[1 ], &remote_ipv6,NULL ,M_WARN ); }net_ctx_init (NULL , &net_ctx); -get_default_gateway (&rgi,0 , &net_ctx); -get_default_gateway_ipv6 (&rgi6, &remote, &net_ctx); +get_default_gateway (&rgi, remote_ipv4, &net_ctx); +get_default_gateway_ipv6 (&rgi6, &remote_ipv6, &net_ctx);print_default_gateway (M_INFO , &rgi, &rgi6);openvpn_exit (OPENVPN_EXIT_STATUS_GOOD );/* exit point */ } -#endif +#endif /* if defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL) */ else if (streq(p[0], "echo") || streq(p[0], "parameter")) {struct buffer string =alloc_buf_gc (OPTION_PARM_SIZE , &gc);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/881?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic438c583a782035ecb9b5ea65702a768ae2585f5
Gerrit-Change-Number: 881
Gerrit-PatchSet: 4
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/881?usp=email )
Change subject: options: add IPv4 support to '--show-gateway <arg>'
......................................................................
options: add IPv4 support to '--show-gateway <arg>'
This is an old debug option, which used to print "the default routes found" for IPv4 and IPv6, and optionally "a route to a particular IPv6 target" if passed an argument.
With the work started in commit 0fcfc8381f60d we want this to handle IPv4 as well, mostly to be able to easily test per-platform get_default_gateway() implementations.
The implementation is simplistic - if <arg> can be parsed as an IPv4 or IPv6 address, that particular protocol lookup will do "the host route" and the other one will stick to "the default route".
NOTE: as of this commit, there is no backend functionality for IPv4, so it will not actually print anything interesting. This will be added in further platform dependent commits.
v2: amend --help output
v3: uncrustify (#ifdef block too long, comments at #endif required now)
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30728.html
---
M doc/man-sections/advanced-options.rst
M src/openvpn/options.c
2 files changed, 20 insertions(+), 10 deletions(-)
doc/man-sections/advanced-options.rst +8 -4
@@ -9,13 +9,17 @@ :: --show-gateway + --show-gateway IPv4-target --show-gateway IPv6-target + For IPv4 it looks for a 0.0.0.0/0 route, or the specified IPv4 address + if the target can be parsed as an IPv4 address. For IPv6 this queries the route towards ::/128, or the specified IPv6 - target address if passed as argument. - For IPv4 on Linux, Windows, MacOS and BSD it looks for a 0.0.0.0/0 route. - If there are more specific routes, the result will not always be matching - the route of the IPv4 packets to the VPN gateway. + target address if the argument is an IPv6 address. + + Adding a target is helpful for diagnostics to see if OpenVPN will do + the right thing if there are more specific IPv4/IPv6 routes to a + VPN server. Advanced Expert Options
src/openvpn/options.c +12 -6
@@ -788,7 +788,7 @@"\n" "General Standalone Options:\n" #ifdef ENABLE_DEBUG -"--show-gateway : Show info about default gateway.\n" +"--show-gateway [address]: Show info about gateway [to v4/v6 address].\n" #endif ;
@@ -5858,20 +5858,26 @@ {struct route_gateway_info rgi;struct route_ipv6_gateway_info rgi6; -struct in6_addr remote =IN6ADDR_ANY_INIT ; +in_addr_t remote_ipv4 =0 ; +struct in6_addr remote_ipv6 =IN6ADDR_ANY_INIT ;openvpn_net_ctx_t net_ctx;VERIFY_PERMISSION (OPT_P_GENERAL );if (p[1 ]) { -get_ipv6_addr (p[1 ], &remote,NULL ,M_WARN ); +/* try parsing the argument as a v4 or v6 address - if +* possible, the output will show the exact route there, and +* "the default route" for the other protocol +*/ + remote_ipv4 =get_ip_addr (p[1 ],M_WARN ,NULL ); +get_ipv6_addr (p[1 ], &remote_ipv6,NULL ,M_WARN ); }net_ctx_init (NULL , &net_ctx); -get_default_gateway (&rgi,0 , &net_ctx); -get_default_gateway_ipv6 (&rgi6, &remote, &net_ctx); +get_default_gateway (&rgi, remote_ipv4, &net_ctx); +get_default_gateway_ipv6 (&rgi6, &remote_ipv6, &net_ctx);print_default_gateway (M_INFO , &rgi, &rgi6);openvpn_exit (OPENVPN_EXIT_STATUS_GOOD );/* exit point */ } -#endif +#endif /* if defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL) */ else if (streq(p[0], "echo") || streq(p[0], "parameter")) {struct buffer string =alloc_buf_gc (OPTION_PARM_SIZE , &gc);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/881?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic438c583a782035ecb9b5ea65702a768ae2585f5
Gerrit-Change-Number: 881
Gerrit-PatchSet: 4
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged